package query;

import java.util.Scanner;

import text.ChineseStem;
import utils.Util;
import index.Document;
import crawl.DocumentParser;

public class QueryStringParser implements DocumentParser
{
    private String content;

    public QueryStringParser(String queryContent)
    {
        this.content = queryContent;
    }

    public Document parse()
    {
        Document.delete(-2);
        Document doc = Document.getDocument(-2);
        String result = ChineseStem.parse(content);
        Scanner scan = new Scanner(result);
        while (scan.hasNext())
        {
            String str = scan.next();
            doc.addTerm(str, Util.getDefaultTermWeight());
        }
        return doc;
    }
}
